import rclpy
from rclpy.node import Node
from base_interfaces.msg import Student
class ListenerStu(Node):
    def __init__(self):
        super(). __init__ ("listenerstu_node_py")
        self.subscription=self.create_subscription(Student,"chatter_stu",self.do_cb,10)
    
    def do_cb(self,msg):
        self.get_logger().info(f"这是订阅的学生信息,姓名：{msg.name},年龄：{msg.age}岁,身高：{msg.height}米")
def main():
    rclpy.init()
    rclpy.spin(ListenerStu())
    rclpy.shutdown()

if __name__=="__main__":
    main()